import ApprovalManagement from '../ApprovalManagement/ApprovalManagement'
import TalentManagement from '../TalentManagement/TalentManagement'
import AccountSetup from '../AccountSetup/AccountSetup'
let Company = {
    path: '/Company',
    name: 'Company',
    component: () => import('../../../views/Company/Home/Company.vue'),
    redirect: '/Company/CompanyHome',
    children: [
        ApprovalManagement,
        TalentManagement,
        AccountSetup,

        {
            //首页
            path: 'CompanyHome',
            name: 'CompanyHome',
            component: () =>
                import('../../../views/Company/Home/CompanyHome.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name);
                switch (from.name) {

                    case 'page1':
                        next();
                        break;
                    case 'Registration':
                        next();
                        break;
                    case 'ApprovalManagement':
                        next();
                        break;
                    case 'MigrationOut':
                        next();
                        break;
                    case 'MigrationIn':
                        next();
                        break;
                    case 'TalentManagement':
                        next();
                        break;
                    case 'Through':
                        next();
                        break;
                    case 'SystemManagement':
                        next();
                        break;
                    case 'Rolemanagement':
                        next();
                        break;
                    case 'ReportForm':
                        next();
                        break;
                    case 'AccountSetup':
                        next();
                        break;
                    case 'AppManger2':
                        next();
                        break;
                    case null:
                        if(sessionStorage.getItem("fName")&&sessionStorage.getItem("fName")=="CompanyHome"){
                        next();
                        }
                        break;
                }
            }
        },
        //职称申报统计表
        {
            path: 'ReportForm',
            name: 'ReportForm',
            component: () => import('../../../views/Company/ReportForm/ReportForm.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name);
                // if (from.name == 'CompanyHome' || 'ApprovalManagement' || 'Registration' || 'MigrationOut' || 'MigrationIn' || 'TalentManagement' || 'Through' || 'SystemManagement' || 'Rolemanagement') {
                //     next();
                // }
                switch (from.name) {
                    case 'CompanyHome':
                        next();
                        break;
                    case 'ApprovalManagement':
                        next();
                        break;
                    case 'Registration':
                        next();
                        break;
                    case 'MigrationOut':
                        next();
                        break;
                    case 'MigrationIn':
                        next();
                        break;
                    case 'TalentManagement':
                        next();
                        break;
                    case 'Through':
                        next();
                        break;
                    case 'SystemManagement':
                        next();
                        break;
                    case 'Rolemanagement':
                        next();
                        break;
                    case 'Talentmanger2':
                        next();
                        break;
                    case 'AppManger2':
                        next();
                        break;
                    case null:
                        if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'ReportForm') {
                        next();
                        }
                        break;
                }
            },
        },
        //通过人员报表
        {
            path: 'Through',
            name: 'Through',
            component: () => import('../../../views/Company/ReportForm/Through.vue'),
            beforeEnter: (to, from, next) => {

                // if (from.name == 'CompanyHome' || 'ApprovalManagement' || 'Registration' || 'MigrationOut' || 'MigrationIn' || 'TalentManagement' || 'ReportForm' || 'SystemManagement' || 'Rolemanagement') {
                //     next();
                // }
                switch (from.name) {
                    case 'CompanyHome':
                        next();
                        break;
                    case 'ApprovalManagement':
                        next();
                        break;
                    case 'Registration':
                        next();
                        break;
                    case 'MigrationOut':
                        next();
                        break;
                    case 'MigrationIn':
                        next();
                        break;
                    case 'TalentManagement':
                        next();
                        break;
                    case 'ReportForm':
                        next();
                        break;
                    case 'SystemManagement':
                        next();
                        break;
                    case 'Rolemanagement':
                        next();
                        break;
                    case 'Talentmanger2':
                        next();
                        break;
                    case 'AppManger2':
                        next();
                        break;
                    case null:
                        if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'Through') {
                        next();
                        }
                        break;
                }
            },
        },
        //角色管理
        {
            path: 'SystemManagement',
            name: 'SystemManagement',
            component: () => import('../../../views/Company/SystemManagement/SystemManagement.vue'),
            beforeEnter: (to, from, next) => {
                next();
                console.log(from.name);
                switch (from.name) {
                    case 'CompanyHome':
                        next();
                        break;
                    case 'ApprovalManagement':
                        next();
                        break;
                    case 'Registration':
                        next();
                        break;
                    case 'MigrationOut':
                        next();
                        break;
                    case 'MigrationIn':
                        next();
                        break;
                    case 'TalentManagement':
                        next();
                        break;
                    case 'ReportForm':
                        next();
                        break;
                    case 'Through':
                        next();
                        break;
                    case 'Rolemanagement':
                        next();
                        break;
                    case 'AppManger2':
                        next();
                        break;
                    case null:
                        if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'SystemManagement') {
                        next();
                        }
                        break;
                }
            },
        },
        //新增角色
        {
            path: 'AddSystemManagement',
            name: 'AddSystemManagement',
            component: () => import('../../../views/Company/SystemManagement/AddSystemManagement.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name);
                if (from.name == 'SystemManagement') {
                    next()
                } else if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'SystemManagement') {
                    next()
                }
            },
        },
        //系统管理
        {
            path: 'Rolemanagement',
            name: 'Rolemanagement',
            component: () => import('../../../views/Company/SystemManagement/Rolemanagement.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name == null);
                // if (from.name == 'CompanyHome' || 'ApprovalManagement' || 'Registration' || 'MigrationOut' || 'MigrationIn' || 'TalentManagement' || 'ReportForm' || 'Through' || 'SystemManagement') {
                //     next();
                // }
                switch (from.name) {
                    case 'CompanyHome':
                        next();
                        break;
                    case 'ApprovalManagement':
                        next();
                        break;
                    case 'Registration':
                        next();
                        break;
                    case 'MigrationOut':
                        next();
                        break;
                    case 'MigrationIn':
                        next();
                        break;
                    case 'TalentManagement':
                        next();
                        break;
                    case 'ReportForm':
                        next();
                        break;
                    case 'Through':
                        next();
                        break;
                    case 'SystemManagement':
                        next();
                        break;
                    case 'GetRolemanagement':
                        next();
                        break;
                    case 'Talentmanger2':
                        next();
                        break;
                    case 'AppManger2':
                        next();
                        break;
                    case null:
                        if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'Rolemanagement') {
                            next();
                        }
                        break;
                }
            },
        },
        //新增管理员
        {
            path: 'GetRolemanagement',
            name: 'GetRolemanagement',
            component: () => import('../../../views/Company/SystemManagement/GetRolemanagement.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name);
                if (from.name == 'Rolemanagement') {
                    next();
                } else if (from.name == 'Getpermissions') {
                    next();
                } else if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'GetRolemanagement') {
                    next();
                }
            },
        },
        //查看权限
        {
            path: 'Getpermissions',
            name: 'Getpermissions',
            component: () => import('../../../views/Company/SystemManagement/Getpermissions.vue'),
            beforeEnter: (to, from, next) => {
                console.log(from.name);
                if (from.name == 'GetRolemanagement') {
                    next();
                } else if (sessionStorage.getItem('fName') && sessionStorage.getItem('fName') == 'Getpermissions') {
                    next();
                }
            },
        }
    ]
}
export default Company